<div class="row">
    <!-- left column -->
    <div class="col-md-12">
        <!-- general form elements -->
        <div class="box box-primary">
            <!-- form start -->
            <?php echo $this->Form->create('search', array('url' => array('controller' => 'video', 'action' => 'index'))); ?>
                <div class="box-body">
                    <div class="row">
                        <div class="form-group col-lg-4">
                            <?php echo $this->Form->input('title',array('class'=>'form-control','placeholder'=>'Title','label'=>__('Title'))); ?>
                        </div>
                        <div class="form-group col-lg-4">
                            <?php echo $this->Form->input('category',array('options'=>$category,'empty'=>'--Select Category--','class'=>'form-control','placeholder'=>'Category','label'=>__('Category'))); ?>
                        </div>
                    </div>
                    <div class="row">
                        <div class="form-group col-lg-4">
                            <?php echo $this->Form->input('startdate',array('class'=>'form-control datepicker','placeholder'=>'Start Date','label'=>__('Start Date'))); ?>
                        </div>
                        <div class="form-group col-lg-4">
                            <?php echo $this->Form->input('enddate',array('class'=>'form-control datepicker','placeholder'=>'End Date','label'=>__('End Date'))); ?>
                        </div>
                    </div>
                </div><!-- /.box-body -->
                <div class="box-footer">
                    <button type="submit" class="btn btn-primary btn-sm"><?php echo __('Search') ?></button>
                </div>
            <?php echo $this->Form->end(); ?>
        </div><!-- /.box -->
    </div><!--/.col (left) -->
</div>

<div class="row">
    <div class="col-xs-12">
        <div class="box">
            <div class="box-body table-responsive">
                <table id="example1" class="table table-bordered table-striped">
                    <thead>
                        <tr>
                            <th><?php echo $this->Paginator->sort('title',__('Title')); ?></th>
                            <th>Description</th>
                            <th><?php echo $this->Paginator->sort('category','Category'); ?></th>
                            <th><?php echo $this->Paginator->sort('user_id','User'); ?></th>
                            <th><?php echo $this->Paginator->sort('status','Status'); ?></th>
                            <th>Preview</th>
                            <th><?php echo $this->Paginator->sort('created','Publish Date'); ?></th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                            if(count($data) > 0){
                            $true = $this->Html->image('test-pass-icon',array('alt'=>'Active'));
                            $false = $this->Html->image('test-fail-icon',array('alt'=>'De-active'));
                            $skey = Configure::read('Security.salt');
                            
                            foreach($data as $key=>$val){
                                $title = strlen($val['Content']['title']) > Configure::read('title_length') ? substr($val['Content']['title'],0,Configure::read('title_length')).'...' : $val['Content']['title'];
                                $description = strlen($val['Content']['description']) > 15 ? substr($val['Content']['description'],0,15).'...' : $val['Content']['description'];
                                
                                $preview = _encode(array('id'=>$val['Content']['id'],'opr'=>'preview'));
                                $detail = _encode(array('id'=>$val['Content']['id'],'opr'=>'detail'));
                                $edit = _encode(array('id'=>$val['Content']['id'],'opr'=>'edit'));
                                $delete = _encode(array('id'=>$val['Content']['id'],'opr'=>'delete'));
                        ?>
                        <tr>
                            <td><?php echo $this->Html->link($title,array('controller'=>'video','action'=>'detail','?'=>array('action'=>$detail))); ?></td>
                            <td><?php echo $description; ?></td>
                            <td><?php echo $val['Category']['category'] != '' ? $val['Category']['category'] : '--'; ?></td>
                            <td><?php echo $val['Content']['user_id'] ?></td>
                            <td><?php echo $val['Content']['status'] == 1 ? $true : $false  ?></td>
                            <td><a href="javascript:void(0)" id="<?php echo $preview ?>" title="<?php echo $title ?>" class="preview">Preview</a></td>
                            <td><?php echo date(Configure::read('date_format'),strtotime($val['Content']['created'])) ?></td>
                            <td>
                                <?php
                                    echo $this->Html->link('Edit',array('controller'=>'video','action'=>'videoopr','?'=>array('action'=>$edit)),array('class'=>'btn btn-info btn-sm')); 
                                    echo '&nbsp;';
                                    echo $this->Html->link('Delete',array('controller'=>'video','action'=>'videoopr','?'=>array('action'=>$delete)),array('class'=>'btn btn-danger btn-sm confirm','message'=>'Are you sure to delete Video'));
                                ?>
                            </td>
                        </tr>
                        <?php }} else { ?>
                        <tr><td colspan="10">No Record Found</td></tr>
                        <?php } ?>
                    </tbody>
                </table>
                
                <?php
                    $pagination = $this->Paginator->params();
                    $this->Paginator->options(array('update'=>'#content','evalScripts'=>true,'data'=>http_build_query($this->request->data),'method'=>'POST'));
                    if($pagination['pageCount'] > 1){
                ?>
                <!-- Pagination start --->
                <div class="row pull-right">
                    <div class="col-xs-12">
                        <div class="dataTables_paginate paging_bootstrap">
                            <ul class="pagination">
                                <?php
                                echo $this->Paginator->prev('← '.__('Previous'),array('tag' => 'li','escape' => false),'<a href="javascript:void(0)">← '.__('Previous').'</a>',array('class' => 'prev disabled','tag' => 'li','escape' => false)); 
                                echo $this->Paginator->numbers(array('currentClass'=>'active','separator'=>false,'currentTag'=>'a','tag' => 'li','escape' => false,'modulus'=>3));
                                echo $this->Paginator->next(__('Next').' →',array('tag' => 'li'),'<a href="javascript:void(0)">'.__('Next').' → </a>',array('class' => 'next disabled','tag' => 'li','escape' => false));
                                ?>
                            </ul>
                        </div>
                    </div>
                </div>
                <!-- Pagination end -->
                <?php echo $this->Js->writeBuffer(); ?>
                <?php } ?>
            </div><!-- /.box-body -->
        </div><!-- /.box -->
    </div>
</div>